package com.burstly.lib.component.networkcomponent.burstly.html.mraid;

import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.SequentAsyncTask;
import com.burstly.lib.util.Utils;

abstract class AbstractParseParamsEvent<T> extends MraidEvent
  implements IPropertiesParsedCallback<T>
{
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = AbstractParseParamsEvent.class.getSimpleName();
  final Class<T> mTargetClass;

  protected AbstractParseParamsEvent(Class<T> paramClass)
  {
    this.mTargetClass = paramClass;
  }

  private void parseProperties(final String paramString, final IPropertiesParsedCallback<T> paramIPropertiesParsedCallback)
  {
    new SequentAsyncTask(10)
    {
      protected void onPostExecute(T paramAnonymousT)
      {
        paramIPropertiesParsedCallback.parsed(paramAnonymousT);
      }

      protected T performInBackground()
      {
        return Utils.fromJson(paramString.replace("'", "\""), AbstractParseParamsEvent.this.mTargetClass);
      }
    }
    .executeSequentially();
  }

  final void fireEvent(MraidView paramMraidView, Object[] paramArrayOfObject)
  {
    if (!checkArgs(paramArrayOfObject))
    {
      LOG.logError(TAG, "Attributes to parse are empty. Skipped.", new Object[0]);
      return;
    }
    if (!setUpEvent(paramMraidView, paramArrayOfObject))
    {
      LOG.logError(TAG, "Attributes are invalid for this view state. Skipped.", new Object[0]);
      return;
    }
    parseProperties((String)paramArrayOfObject[0], this);
  }

  protected abstract boolean setUpEvent(MraidView paramMraidView, Object[] paramArrayOfObject);
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.burstly.html.mraid.AbstractParseParamsEvent
 * JD-Core Version:    0.6.2
 */